//
//  UIViewAdditions.h
//  Tint
//
//  Created by Kevin Wu on 2/22/12.
//  Copyright (c) 2012 Telligenty. All rights reserved.
//

#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>


@interface UIView (Tint)

/*
 * Accessors
 */
@property(nonatomic, assign) CGFloat leftX;
@property(nonatomic, assign) CGFloat centerX;
@property(nonatomic, assign) CGFloat rightX;

@property(nonatomic, assign) CGFloat topY;
@property(nonatomic, assign) CGFloat centerY;
@property(nonatomic, assign) CGFloat bottomY;

@property(nonatomic, assign) CGFloat width;
@property(nonatomic, assign) CGFloat height;

@property(nonatomic, assign) CGPoint origin;
@property(nonatomic, assign) CGSize size;

@property(nonatomic, readonly) UIImage *imageRepresentation;
@property(nonatomic, readonly) UIViewController *viewController;

@property(nonatomic, readonly) UIView *rootView;


/*
 * Adding and removing subview
 */
- (void)addCenteredSubview:(UIView *)subview;
- (void)removeAllSubviews;

/*
 * Placing
 */
- (void)occupySuperview;
- (void)moveToCenterOfSuperview;
- (void)moveToVerticalCenterOfSuperview;
- (void)moveToHorizontalCenterOfSuperview;
- (void)setFrameIfNeeded:(CGRect)frame;
- (void)setCenterIfNeeded:(CGPoint)center;

/*
 * Finding views
 */
- (UIView *)findFirstResponder;
- (NSArray *)newSuperviewsArray;
- (NSArray *)newSubviewsArrayWithClass:(Class)cls;
- (UIView *)descendantOrSelfWithClass:(Class)cls;
- (UIView *)ancestorOrSelfWithClass:(Class)cls;

/*
 * Hierarchy
 */
- (void)bringToFront;
- (void)sendToBack;
- (BOOL)isInFront;
- (BOOL)isAtBack;

/*
 * Debug
 */
- (void)showBorderWithRandomColor;
- (void)showBorderWithColor:(UIColor *)color;
+ (void)showBorder:(UIView *)view;
+ (void)showBorder:(UIView *)view withColor:(UIColor *)color;
+ (void)dumpView:(UIView *)view level:(NSInteger)level;

@end
